package com.briup.cms.web.controller;

import com.briup.cms.service.ICms_configService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "配置接口")
@RestController
@RequestMapping("/cms_config")
public class Cms_configController {

    @Autowired
    private ICms_configService cms_configService;

    @ApiOperation("查询所有")
    @GetMapping("findAll")
    public Message findAll() {
        List<Cms_config> list = cms_configService.findAll();
        return MessageUtil.success(list);
       }

    @ApiOperation("保存或更新")
    @GetMapping("saveOrUpdate")
    public Message saveOrUpdate(Cms_config cms_config){
        cms_configService.saveOrUpdate(cms_config);
        return MessageUtil.success( "操作成功");
    }


    @ApiOperation("删除")
    @PostMapping("deleteById")
    public Message deleteById(long id){
        cms_configService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
